//
//  SecondScrollView.m
//  UI09_homework
//
//  Created by 洛洛大人 on 16/6/17.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "SecondScrollView.h"

@interface SecondScrollView() <UIScrollViewDelegate>

@end


@implementation SecondScrollView


-(instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    
    if (self) {
        [self setPropertys];

   }
    return self;
    
}

-(void)setPropertys {
    
    
    self.contentSize = CGSizeMake(2000, 0);
    
    self.showsHorizontalScrollIndicator = NO;
    self.showsVerticalScrollIndicator = NO;
    
    self.pagingEnabled = YES;
    
}



-(void)addPicture:(NSArray<UIImage *> *)pictureArray {
    
    for(int i = 0; i<pictureArray.count; i++) {
        
        UIScrollView *scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(i * CGRectGetWidth(self.bounds), 0 , CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))];
        
        self.delegate = self;
        
        scroll.maximumZoomScale = 2;
        scroll.minimumZoomScale = 0.5;
        
        self.contentSize = CGSizeMake(CGRectGetWidth(self.bounds) * pictureArray.count, CGRectGetHeight(self.bounds));
        
        UIImageView *imageView = [[UIImageView alloc]initWithImage:pictureArray[i]];
        imageView.frame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds));
        
        [scroll addSubview:imageView];
        
        [self addSubview:scroll];
        [imageView release];
        [scroll release];
        
    }
                                                                            
}





@end
